<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Animal(name) {
        this.name = name;
        this.getName = function () {
          return this.name;
        };
      }
      Animal.prototype.say = function () {
        console.log("hello" + this.name);
      };
      function Dog(name) {
        Animal.call(this, name);
      }

      var dog1 = new Dog("张三");
      // 在子类构造函数中 ,直接将父类中的构造函数执行一遍,拿到了父类构造函数中的属性 和方法
      // 不会出现共享的问题
      console.log(dog1);
      // 但是 原型上的属性和方法无法继承
      dog1.say();
    </script>
  </body>
</html>
